package com.tulingxueyuan.mall.controller;

import com.tulingxueyuan.mall.common.api.CommonResult;
import com.tulingxueyuan.mall.dto.HomeGoodsSaleDTO;
import com.tulingxueyuan.mall.dto.HomeMenusBannerDTO;
import com.tulingxueyuan.mall.dto.HomeMenusDTO;
import com.tulingxueyuan.mall.modules.pms.service.PmsProductCategoryService;
import com.tulingxueyuan.mall.modules.sms.model.SmsHomeAdvertise;
import com.tulingxueyuan.mall.modules.sms.service.SmsHomeAdvertiseService;
import com.tulingxueyuan.mall.modules.sms.service.SmsHomeCategoryService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页控制器
 */


@RestController
@RequestMapping("/home")
@Api(tags = "HomeController" ,description = "首页内容管理")
public class HomeController {
    @Autowired
    private PmsProductCategoryService productCategoryService;
    @Autowired
    private SmsHomeAdvertiseService homeAdvertiseService;
    @Autowired
    private SmsHomeCategoryService homeCategoryService;


    /**
     * 获取首页菜单类型导航栏数据
     * get("/home/menus")
     */

    @RequestMapping(value = "/menus_banner",method = RequestMethod.GET)
    public CommonResult getMenus() {
        //分类导航
        List<HomeMenusDTO> list = productCategoryService.getMenu();
        // banner

        List<SmsHomeAdvertise> homeAdvertiseList = homeAdvertiseService.getHomeBanner();
        HomeMenusBannerDTO homeMenusBannerDTO = new HomeMenusBannerDTO();
        homeMenusBannerDTO.setHomeMenusList(list);
        homeMenusBannerDTO.setHomeAdvertiseList(homeAdvertiseList);
        return CommonResult.success(homeMenusBannerDTO);

    }

    /**
     *         this.axios.get("/home/goods_sale").then((res)=>{
     * @return
     */
    @RequestMapping(value = "/goods_sale",method = RequestMethod.GET)
    public CommonResult getGoodsSale() {
        List<HomeGoodsSaleDTO> list = homeCategoryService.getGoodsSale();
        return CommonResult.success(list);



    }
}
